package leetcode.二叉树;

public class 对称二叉树101 {
    public static boolean isSymmetric(TreeNode root) {
        if(root.left==null && root.right == null){
            return true;
        }
        if(root.left == null || root.right == null){
            return false;
        }
        return process(root.left,root.right);


    }

    private static boolean process(TreeNode left, TreeNode right) {
        if(left == null && right == null)
            return true;
        if(left == null || right == null)
            return false;
        if(left.val != right.val){
            return false;
        }
        return process(left.left,right.right) && process(left.right,right.left);
    }
}
